# 使用官方Python 3.13镜像
FROM python:3.13-slim

# 备份原始源文件（可选）
RUN cp /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.bak

# 替换为阿里云源
RUN sed -i 's|http://deb.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources && \
    sed -i 's|http://security.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources

# 安装时区工具
RUN apt-get update && \
    apt-get install -y tzdata && \
    rm -rf /var/lib/apt/lists/*

# 配置pip国内源
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ || \
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

# 定义应用路径变量
ARG APP_PATH
ARG PY_ENTRY
WORKDIR /paper-pro

# 使用变量替代硬编码路径
COPY setup.py setup.py
COPY ${APP_PATH}/requirements.txt requirements.txt
RUN pip install -e . && \
    pip install --no-cache-dir -r requirements.txt

WORKDIR /paper-pro/${APP_PATH}
ENV PY_ENTRY=$PY_ENTRY
CMD ["sh", "-c", "python ${PY_ENTRY}"]